<template>
  <div>
    <!-- 轮播图部分 -->
    <div>
      <el-carousel height="600px" :autoplay="true" :interval="5000" indicator-position="outside">
        <el-carousel-item v-for="(img, index) in images" :key="index">
          <img :src="img" alt="banner image" style="width: 100%; height: 100%; object-fit: fill;" />
        </el-carousel-item>
      </el-carousel>
    </div>

    <!-- 新闻资讯部分 -->
    <div class="news">
      <div class="title">
        <h3>新闻资讯</h3>
        <em>News &amp; Updates</em>
      </div>
      <div style="padding: 40px 150px;">
        <!-- 新闻走马灯 -->
        <el-carousel :autoplay="false" :interval="0" arrow="always" :items-to-show="1" :items-to-scroll="1">
          <!-- 每个 carousel-item 显示三个 box -->
          <el-carousel-item v-for="(group, index) in groupedNews" :key="index">
            <el-row :gutter="20" style="padding: 0 100px;">
              <el-col v-for="(news, i) in group" :key="i" :span="8">
                <div class="box">
                  <div class="title">
                    <div class="time">
                      <p>{{ formatDate(news.bidPublishDatetime).monthYear }}</p>
                      <h3>{{ formatDate(news.bidPublishDatetime).day }}</h3>
                    </div>
                    <div class="txth">
                      <a :href="news.link" tabindex="0">{{ news.bidTitle }}</a>
                    </div>
                  </div>
                  <div class="text">
                    <p>{{ truncatedContent(news.bidContent) }}</p>
                    <a class="more" :href="news.link" tabindex="0" @click="jumpTo(news.id)">详细 &gt;&gt;</a>
                  </div>
                </div>
              </el-col>
            </el-row>
          </el-carousel-item>
        </el-carousel>
      </div>
      <div class="lookbox">
        <a class="look" href="/bid/list">查看更多</a>
      </div>
    </div>
    <div class="info">
      <div class="wal">
        <div class="leftbox">
          <div class="title">
            <h3>走进医药港</h3>
            <p>About GIMP</p>
          </div>
          <div class="text">
            <p>
              &nbsp;杭州医药港2017年启动建设；2018年5月，杭州市政府授予“杭州医药港”称号；2019年，获批创建浙江省级产业创新服务综合体；2020年，获批建设省级“万亩千亿”新产业平台；2021年，获市“先进基层党组织”“最强产业小镇”“浙江省级特色小镇”命名
            </p>
          </div>
          <div class="lookbox"><a class="look" href="">详细介绍</a></div>
        </div>

        <div class="glist">
          <el-row :gutter="20">
            <el-col :span="8" v-for="(img, index) in images" :key="index">
              <div class="box">
                <div class="imgDiv">
                  <a href=""><img :src="img" alt="Image {{index + 1}}" /></a>
                </div>
                <div class="text">
                  <a href="" class="txt">
                    <el-icon class="ico">
                      <SuitcaseLine v-if="index == 0" />
                      <Stopwatch v-if="index == 1" />
                      <TakeawayBox v-if="index == 2" />
                    </el-icon>
                    <p>{{ descriptions[index] }}</p>
                  </a>
                </div>
              </div>
            </el-col>
          </el-row>
        </div>
      </div>
    </div>
    <div class="indexPart3">
      <div class="wal">
        <div class="about">
          <div class="title">
            <h3>走进医药港</h3>
            <p>About GIMP</p>

          </div>
          <div class="text">
            杭州医药港小镇位于杭州经济技术开发区西北部，规划范围北至新建河，南至德胜快速路，东至文渊北路，西至乔下线，总面积约 5.17 平方公里。坚持国际化理念、全球化视野，聚焦全球生物医药资源和要素集聚，重点推进产业链、创新链、生态链、人才链、金融链、服务链“六链”融合，打造国内顶尖、世界一流的生物医药研发创新高地。 </div>
          <div class="list">
            <ul>
              <li>
                <div class="box">

                  <el-icon class="ico">
                    <AddLocation />
                  </el-icon>
                  <p class="tx">占地面积</p>
                  <p>341公顷</p>
                </div>
              </li>
              <li>
                <div class="box">
                  <el-icon class="ico">
                    <OfficeBuilding />
                  </el-icon>
                  <p class="tx">建筑面积</p>
                  <p>558万平方米</p>
                </div>
              </li>
              <li>
                <div class="box">
                  <el-icon class="ico">
                    <Coin />
                  </el-icon>
                  <p class="tx">总投资</p>
                  <p>300亿元</p>
                </div>
              </li>
            </ul>
            <div class="clear_f"></div>
          </div>
          <div class="imgDiv phshow"><img src="@/assets/images/nimg640_bg2.jpg"></div>
          <div class="lookbox"><a class="look" href="">了解更多</a></div>
        </div>
      </div>
    </div>
    <div class="indexPart4 pcshow">
      <div class="wal">
        <div class="content">
          <em>友情链接</em>
          <div class="list">
            <ul>
              <li><a href="https://www.paohe.cn/home" target="_blank">跑合网中药材B2B服务平台</a></li>
              <li><a href="http://www.nhc.gov.cn/" target="_blank">中华人民共和国国家卫生健康委员会</a></li>
              <li><a href="http://www.most.gov.cn/" target="_blank">中华人民共和国科学技术部</a></li>
              <li><a href="http://www.samr.gov.cn/" target="_blank">国家市场监督管理总局</a></li>
              <li><a href="http://www.satcm.gov.cn/" target="_blank">国家中医药管理局</a></li>
            </ul>
          </div>
        </div>
      </div>
    </div>
    <div class="footDiv pcshow">
      <div class="wal">
        <div class="link">
          <a href="/index.html">首页</a><span>|</span>
          <a href="">关于我们</a><span>|</span>
          <a href="">走进医药港</a><span>|</span>
          <a href="">品牌合作</a><span>|</span>
          <a href="">招商中心</a><span>|</span>
          <a href="">资讯中心</a><span>|</span>
          <a href="">加入我们</a><span>|</span>
        </div>
        <div class="msg">Copyright © www.gimp.net.cn All Rights Reserved <a href=""
            target="_blank"></a><br><a href="" target="_blank">Powered by
            vancheer</a></div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { listBidding } from '@/api/bid/bidding'
const router = useRouter();
const bidData1 = ref(null)
// 模拟新闻数据
const images = ref([
  new URL('@/assets/images/背景1.jpg', import.meta.url).href,
  new URL('@/assets/images/背景2.png', import.meta.url).href,
  new URL('@/assets/images/背景3.jpg', import.meta.url).href,
])
const descriptions = ref([
  '总规划|多业态',
  '交通区位优势',
  '招商中心'
])
// 将新闻数据分组，每组三个
const groupedNews = ref([])
const groupNews = () => {
  const groupSize = 3
  groupedNews.value = []
  for (let i = 0; i < bidData1.value.length; i += groupSize) {
    groupedNews.value.push(bidData1.value.slice(i, i + groupSize))
  }
}
// 日期格式化函数
const formatDate = (dateString) => {
  const date = new Date(dateString);
  const monthYear = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}`;
  const day = String(date.getDate()).padStart(2, '0');
  return { monthYear, day };
}

// 截取内容函数
const truncatedContent = (content) => {
  return content.length > 70 ? content.slice(0, 70) + '...' : content;
}
const jumpTo = (id) => {
  router.push(`/bid/detail?id=${id}`)
}
const getData = async () => {
  bidData1.value = (await listBidding({ category: 5 })).rows
  console.log(bidData1.value)
  // bidData2.value = (await listBidding({category: 6})).rows
}
// 获取数据
onMounted(async () => {
  await getData()
  await groupNews() // 进行分组
})
</script>

<style scoped lang="scss">
* {
  padding: 0px;
  margin: 0px;
}

.news {
  display: block;
  margin-top: 20px;
  padding-bottom: 40px;

  .title {
    text-align: center;

    h3 {
      font-weight: inherit;
      font-size: 24px;
      color: #008a17;
      background: url(@/assets/images/ico1_1hr.png) no-repeat center;
      margin: 0;
      padding: 0;
    }

    em {
      font-size: 16px;
      color: #008a17;
      opacity: 0.5;
      text-transform: uppercase;
      font-style: normal;
      margin: 0;
      padding: 0;
    }
  }

  .box {
    margin: 0 10px;
    border: 1px #eee solid;

    .title {
      height: 70px;
      position: relative;

      .time {
        position: absolute;
        left: 0;
        top: 0;
        width: 85px;
        height: 70px;
        background-color: #6dd164;
        text-align: center;

        p {
          height: 30px;
          line-height: 30px;
          background-color: #52cc62;
          font-size: 14px;
          color: #fff;
          opacity: 0.5;
          padding: 0px;
          margin: 0px;
        }

        h3 {
          font-weight: inherit;
          font-size: 24px;
          color: #fff;
          line-height: 40px;
          padding: 0px;
          margin: 0px;
        }
      }

      .txth {
        padding-left: 102px;
        padding-right: 20px;
        padding-top: 26px;
        font-size: 16px;
        color: #333;

        a {
          color: #333;
        }
      }
    }

    .text {
      margin: 20px;
      border-top: 1px #eee solid;
      padding-top: 20px;
      font-size: 14px;
      color: #999;
      line-height: 2;

      p {
        color: #666;
        text-align: left;
      }

      .more {
        color: #bababa;
      }
    }
  }

  .lookbox {
    height: 52px;

    .look {
      display: block;
      width: 190px;
      height: 50px;
      margin: 0 auto;
      line-height: 50px;
      text-align: center;
      font-size: 14px;
      color: #999;
      border: 1px #eee solid;
      transition: all 0.5s;
      -webkit-transition: all 0.5s;
    }

    .look:hover {
      color: #fff;
      background: url(@/assets/images/ico1_3bg.png) no-repeat center;
      border: none;
      box-shadow: 0 1px 15px rgba(0, 73, 138, 0.3);

    }

    a:hover {
      text-decoration: none;
      color: #19a30c;
      outline: none;
    }
  }

}

.info {
  display: block;
  padding: 50px 0;
  min-height: 500px;
  background: url(@/assets/images/nimg1920_bg1.jpg) no-repeat bottom center;
  background-color: #f5f5f5;

  .wal {
    position: relative;
    width: 1240px;
    margin: 0px auto;

    .leftbox {
      position: absolute;
      left: 0;
      top: 0;
      width: 295px;
      height: 406px;
      background-color: #fff;
      text-align: center;
      transition: all 0.5s;
      -webkit-transition: all 0.5s;

      .title {
        margin-top: 55px;
        margin-bottom: 40px;

        h3 {
          font-weight: inherit;
          font-size: 24px;
          color: #008a17;
          background: url(@/assets/images/ico1_1hr.png) no-repeat center;
        }

        p {
          font-size: 16px;
          color: #008a17;
          opacity: 0.5;
          text-transform: uppercase;
        }
      }

      .text {
        padding: 0 28px;
        font-size: 14px;
        color: #bababa;
        line-height: 1.75;
      }

      .lookbox {
        height: 52px;
        margin-top: 40px;

        .look {
          display: block;
          width: 190px;
          height: 50px;
          margin: 0 auto;
          line-height: 50px;
          text-align: center;
          font-size: 14px;
          color: #999;
          border: 1px #eee solid;
          transition: all 0.5s;
          -webkit-transition: all 0.5s;
        }

        .look:hover {
          color: #fff;
          background: url(@/assets/images/ico1_3bg.png) no-repeat center;
          border: none;
          box-shadow: 0 1px 15px rgba(0, 73, 138, 0.3);
        }

        a:hover {
          text-decoration: none;
          color: #19a30c;
          outline: none;
        }
      }
    }
  }

  .glist {
    margin-left: 316px;
    padding-top: 63px;
    position: relative;
    display: block;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -khtml-user-select: none;
    -ms-touch-action: pan-y;
    touch-action: pan-y;
    -webkit-tap-highlight-color: transparent;
    outline: none;

    .box {
      margin: 0 12px;

      .imgDiv {
        display: block;
        width: 300px;
        height: 200px;

        img {
          width: 300px;
          border: 0px;
          height: 200px;
          vertical-align: middle;

        }
      }

      .text {
        height: 82px;
        position: relative;

        .txt {
          position: absolute;
          z-index: 22;
          left: 50%;
          margin-left: -111px;
          bottom: 20px;
          display: block;
          width: 255px;
          height: 100px;
          background-color: #fff;
          text-align: center;
        }

        .ico {
          color: #19a30c;
          font-size: 36px;
          height: 65px;
          line-height: 70px;
        }

        p {
          font-size: 14px;
          color: #999;
        }
      }
    }
  }
}

.indexPart3 {
  padding-top: 45px;
  padding-bottom: 60px;
  background: url(@/assets/images/nimg1920_bg3.jpg) no-repeat bottom center;

  .wal {
    width: 1240px;
    margin: 0px auto;

    .about {
      width: 730px;

      .title {
        text-align: center;
        margin-bottom: 40px;

        h3 {
          font-weight: inherit;
          font-size: 24px;
          color: #008a17;
          background: url(@/assets/images/ico1_1hr.png) no-repeat center;
        }

        p {
          font-size: 16px;
          color: #008a17;
          opacity: 0.5;
          text-transform: uppercase;
        }
      }

      .text {
        font-size: 14px;
        color: #999;
        line-height: 2;

      }

      .list {
        margin-top: 30px;
        margin-bottom: 267px;

        li {
          width: 33.33%;
          float: left;
          text-align: center;
          list-style-position: outside;
          list-style-type: none;

          .box {
            padding: 20px 0;
            border-right: 1px #eee solid;

            .tx {
              font-size: 14px;
              color: #008a17;
            }

            .ico {
              font-size: 38px;
              color: #008a17;
            }

            p {
              font-size: 24px;
              color: #008a17;
              opacity: 0.7;
            }
          }

          .clear_f {
            clear: both;
            height: 0px;
            padding: 0px;
            margin: 0px;
            display: block;
          }
        }
      }

      .phshow {
        display: none;

        img {
          border: 0px;
          vertical-align: middle;
        }
      }

      .lookbox {
        height: 52px;

        .look {
          display: block;
          width: 190px;
          height: 50px;
          line-height: 50px;
          text-align: center;
          font-size: 14px;
          color: #999;
          border: 1px #eee solid;
          transition: all 0.5s;
          -webkit-transition: all 0.5s;
          color: #fff;
        }

        .look:hover {
          color: #fff;
          background: url(@/assets/images/ico1_3bg.png) no-repeat center;
          border: none;
          box-shadow: 0 1px 15px rgba(0, 73, 138, 0.3);
        }

        a:hover {
          text-decoration: none;
          color: #19a30c;
          outline: none;
        }
      }
    }
  }
}

.indexPart4 {
  .wal {
    position: relative;
    height: 100px;
    width: 1240px;
    margin: 0px auto;

    .content {
      position: absolute;
      left: 0;
      bottom: -50%;
      width: 100%;
      height: 100px;
      background-color: #fff;
      box-shadow: 0 1px 25px rgba(0, 0, 0, 0.1);
    }

    em {
      float: left;
      display: block;
      width: 100px;
      text-align: center;
      line-height: 100px;
      background-color: #0ca425;
      font-size: 14px;
      color: #fff;
    }

    .list {
      position: absolute;
      right: 0;
      top: 37px;
      width: 1140px;
      line-height: 2;
      height: 30px;
      overflow: hidden;
      background-color: #fff;

      ul {
        padding-right: 80px;

        li {
          display: inline-block;
          list-style-position: outside;
          list-style-type: none;

          a {
            display: block;
            font-size: 14px;
            color: #999;
            margin: 0 18px;
          }
        }
      }
    }
  }
}

.footDiv {
  padding-top: 90px;
  padding-bottom: 25px;
  // background: url(@/assets/images/foot.jpg) no-repeat bottom center;
  background-color: #001500;

  .wal {
    width: 1240px;
    margin: 0px auto;

    .link {
      text-align: center;
      font-size: 14px;
      color: #fff;
      padding-bottom: 25px;

      a {
        color: #fff;
      }

      span {
        padding: 0 20px;
      }
    }

    .msg {
      text-align: center;
      color: #5d6b7a;
      line-height: 2;
      margin-top: 25px;
    }
  }
}
</style>
